<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <link rel="stylesheet" href="${ctxStatic}/tree/css/mailCss/noneStyle.css" type="text/css"/>
    <title>日程管理</title>
    <meta name="decorator" content="default"/>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport"/>
    <style>
        #jbox-content{
            width: 300px;
        }
        table,table>tr,table>tr>td{ width: 100% !important;
            float: left;}
    </style>
    <script type="text/javascript">
        function js_method() {
            $("#mytable").append("")
        }

        $(document).ready(function () {
        });


        //存为草稿箱
        function deleteBy() {
            form1.action = '${ctx}/oa/mailInfo/saveDrafts';
            form1.submit();
        }

        function send(){
            var rr = document.getElementById("rr").value;
            var  re= document.getElementById("receiverIdName").value;
            var theme = document.getElementById("theme").value;

            if ((rr == "") && ( re == "")){
                confirm("请输入收件人地址");
//                document.getElementById("ss").innerHTML = "<div style='color: #ffffff;background-color: #EF8F00;width: 200px;height: 30px;text-align: center;position: absolute;bottom: 8px;left: -650px;line-height: 30px;'>请输入收件人地址</div>";
                return;
            }
            else{
                if (theme.length > 120) {
                    confirm("主题长度不能超过120个中文字符");
//                    document.getElementById("ss").innerHTML = "<div style='color: #ffffff;background-color: #EF8F00;width: 190px;height: 20px;text-align: center;position: absolute;left: -650px;bottom: 10px'>主题长度不能超过120个中文字符</div>";
                    return;
                }else{
                    if(theme==""){
                        if (confirm('您的邮件没有填写主题，您确定要发送吗？')) {
                            if (rr != null && re!=""){
                                form1.action = '${ctx}/oa/mailInfo/send?in=1&out=1';
                                form1.submit();

                            }
                            if(rr=="" && re != ""){
                                form1.action = '${ctx}/oa/mailInfo/send?in=1&out=0';
                                form1.submit();
                            }
                            if(re=="" && rr != ""){
                                form1.action = '${ctx}/oa/mailInfo/send?in=0&out=1';
                                form1.submit();
                            }

                        }else{
                            return;
                        }
                    }else{
                        if (rr != "" && re!=""){
                            form1.action = '${ctx}/oa/mailInfo/send?in=1&out=1';
                            form1.submit();

                        }
                        if(rr=="" && re != ""){
                            form1.action = '${ctx}/oa/mailInfo/send?in=1&out=0';
                            form1.submit();
                        }
                        if(re=="" && rr != ""){
                            form1.action = '${ctx}/oa/mailInfo/send?in=0&out=1';
                            form1.submit();
                        }
                    }
                }
            }
        }



        $(function(){
            $("#file_upload").change(function(){
                $("#ctlImg").attr("src",$(".filename").html());
                console.log($(".filename").html());
            });
        });
        $(document).ready(function () {
            $('#file_upload').uploadify({
                'swf': '${ctxStatic}/uploadify/uploadify.swf',
                //'uploader'：若是上传路径
                'uploader': '${ctx}/oa/personSigns/saveContractFile',
                'buttonText': '请选择要上传的附件',
                'height': 25,
                'width': 150,
                'auto': false,
                'fileTypeExts': '*.*',
                "fileObjName": 'file',
                'multi': false,
                'onUploadSuccess': function (file, data, response) {
                    console.log(file);
                    //若是上传成功，跳转的页面
                    location.href = "${ctx}/oa/personSigns/list";
                },
                'onCancel': function () {
                    flag = false;
                },
                'onSelect': function () {
                    flag = true;
                },
                'onUploadStart': function (file) {
                    $("#file_upload").uploadify("settings", "formData", {
                        'name': $("#name").val(),'signName':$("#signName").val(),
                        'id':$("#id").val()
                    });
                }
            });
            $("#btnSubmit").on("click", function () {
                $('#file_upload').uploadify('upload', '*');
            })

        });

    </script>
    <style>
        #btnMenu{
            display: none;}
        .breadcrumb{ padding:25px 15px}
        .title_Infor{
            width: 100%;
            float: left;
            background-color: #33aafb;
            border-bottom: none;
            margin-top:0px !important;
            line-height: 30px;
            height: 37px;
        }
        .title_Infor>a{
            color: #fff;}
        .title_Infor img{
            height:18px;
        }
        .title_Infor h3{
            width: calc(100% - 100px);
            color: #fff;
            font-size: 18px;
            text-align: center;
            margin: 0;
            float: left;
        }
        #searchForm{
            float: left;}
        .td,.td1{ width: 100%;float: left; text-align: left}
        .td>input,.td1>input{ width: 87%;}
        body{ overflow-x: hidden   }
        .input-xxlarge{
            width:100%;}
        .input-append{ width: 75%}
        tbody{
        padding: 0 15px;
            float: left;
            width: 100%;
        }
        tr{ width: 100%;
            float: left;}
    </style>


</head>
<body style="overflow-x: hidden">

<div class="title_Infor" style="margin-top: 0px;margin-bottom: 0px">
    <a href="${ctx}/login" class="pull-left" style="margin: 4px"><img src="${ctxStatic}/oaApp/img/liucheng_Icon/fanhui.png" />返回</a>
    <h3>邮件编辑</h3>
</div>


<div style="background-color: #ffffff; float: left; margin-bottom: 60px; width: 100%; margin-top: 20px;">

    <table style="width:100%" id="mytable" id="tb01">
        <form:form modelAttribute="mailInfo" action="" method="post" id="form1"
                   class="form-horizontal">
            <form:hidden path="id"></form:hidden>
            <tr>
                <td class="td1">外部收件人</td>
                <td class="td">
                    <div class="controls" style="width: 100%">
                        <form:input path="outSide" htmlEscape="true" type="text"
                                    style="width:87%;" id="rr"></form:input>
                    </div>
            </tr>
            <tr>
                <td class="td1" class="person">收件人</td>
                <td class="td">
                    <div class="controls" class="1111">
                        <sys:treeselect id="receiverId" name="receiverId"
                                        value="${mailInfo.receiverId}" labelName="name"
                                        labelValue="${mailInfo.receiverNames}"
                                        title="用户" url="/sys/office/treeData?type=3"
                                        notAllowSelectParent="true" checked="true" cssStyle="width:100%"/>
                        <span class="help-inline"><font color="red">*</font> </span>
                    </div>
            </tr>

            <tr>
                <td class="td1" class="person">群组收件</td>
                <td class="td">
                    <div class="controls" >
                        <form:select path="outSide" cssStyle="width: 91%">
                            <form:option value="" label="请选择" ssStyle="width:100%" />
                            <form:options items="${descriptionList}" itemlabel="label" itemvalue="value" htmlescape="false"/>
                        </form:select>

                    </div>
            </tr>


            <tr>
                <td class="td1">抄送人</td>
                <td class="td">
                        <sys:treeselect id="ccId" name="ccId"
                                        value="${mailInfo.ccId}" labelName="name" labelValue="${mailInfo.ccNames}"
                                        title="用户" url="/sys/office/treeData?type=3" cssClass="input-xxlarge required"
                                        notAllowSelectParent="true" checked="true" cssStyle="width:100%"/>
                    <span class="help-inline"><font color="red">*</font> </span>
            </tr>
            <tr>
                <td class="td1">主题</td>
                <td class="td">
                    <form:input path="theme" htmlEscape="false" type="text"
                                style="width:87%" value="${mailInfo.theme}" id="theme"></form:input>
                </td>
            </tr>
            <tr>
                <td class="td1">附件</td>
                <td class="td" style="padding-bottom: 15px; height: 25px">
                    <input type="file"  name="file_upload" id="file_upload" value="选择文件"/>
                        <%--<form:hidden id="files" path="files" htmlEscape="false" maxlength="2000" class="input-xlarge"/>--%>
                        <%--<sys:ckfinder input="files" type="files" uploadPath="/oa/mailInfo" selectMultiple="true"/>--%>
                </td>

            </tr>
            <tr>
                <td class="td1" valign="top">正文</td>
                <td style="padding-left: 7px;float: left;     width: 87%;">
                    <form:textarea id="content" path="content" rows="3" maxlength="200"
                                   class="input-xxlarge"/>
                </td>
            </tr>
            <tr style=" ">
                <td colspan="2" style=" ">发件人: <span>
                        ${fns:getUser().name}
                </span></td>
            </tr>
            <tr>
                <td colspan="2" style=" padding-top: 7px">
                    <input type="submit" class="btn btn-success" style="width: 40%" value="发送" onclick="send()">　
                    <input type="submit" class="btn btn-success" style="width: 47%" value="存草稿" onclick="deleteBy()">
                </td>
            </tr>
        </form:form>
    </table>
</div>
<script>
    $(function(){
        $("#jbox-content")
    })
</script>
</body>
</html>